package com.byq.mm.application.cluster.server;

import com.byq.mm.abstractx.device.Device;
import com.byq.mm.abstractx.engine.CoreEnvironment;
import com.byq.mm.abstractx.protocol.Interaction;
import com.byq.mm.application.cluster.datatype.SimpleLocation;
import com.byq.mm.application.cluster.provider.LocationProvider;
import com.byq.mm.foundation.cluster.datatype.AttributeValue;
import com.byq.mm.foundation.cluster.server.BasicClusterServer;

import java.util.ArrayList;
import java.util.Collection;

import com.byq.mm.abstractx.device.Device;
import com.byq.mm.abstractx.engine.CoreEnvironment;
import com.byq.mm.abstractx.protocol.Interaction;
import com.byq.mm.application.cluster.provider.LevelControlProvider;
import com.byq.mm.application.cluster.server.executor.LevelControlExecutor;

import com.byq.mm.foundation.cluster.datatype.AttributeValue;
import com.byq.mm.foundation.cluster.datatype.DoubleRangeValue;
import com.byq.mm.foundation.cluster.datatype.DoubleValue;
import com.byq.mm.foundation.cluster.server.BasicClusterServer;

public class LocationServer extends BasicClusterServer {

	public LocationServer(String cluster, Device device, CoreEnvironment env) {
		super(cluster, device, env);
	}

	@Override
	public boolean onCommand(Interaction i, String transport) {
		return super.onCommand(i, transport);
		
		
		
	}
	public void onLocationChange(SimpleLocation value){
		attributes.put(LocationProvider.Define.Attributes.LOCATION, value);
		this.broadcastAttributeToSubscription(LocationProvider.Define.Attributes.LOCATION);
		
	}

	@Override
	protected Class<? extends AttributeValue> getAttributeType(String attributeName) {
		if(attributeName.equals(LocationProvider.Define.Attributes.LOCATION))
			return SimpleLocation.class;
		return null;
	}

	@Override
	protected void init() {

		attributes.put(LocationProvider.Define.Attributes.LOCATION,new SimpleLocation());
		subscriber.put(LocationProvider.Define.Attributes.LOCATION,  new ArrayList<String>());
		
	}


}
